﻿using Microsoft.WindowsAzure;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace ProductCatalog.WebApi.DataLayer
{
    public static class CloudConfiguration
    {
        public static string GetMongolabConnectionString()
        {
            try
            {
                if (Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable)
                    return CloudConfigurationManager.GetSetting("MongolabConnectionString");
            }
            catch
            {
            }


            return ConfigurationManager.AppSettings["MongolabConnectionString"];
        }

        public static string GetProductDatabaseName()
        {
            try
            {
                if (Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable)
                    return CloudConfigurationManager.GetSetting("ProductDatabaseName");
            }
            catch
            {
            }

            return ConfigurationManager.AppSettings["ProductDatabaseName"];
        }

        public static string GetProductCollectionName()
        {
            try
            {
                if (Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable)
                    return CloudConfigurationManager.GetSetting("ProductCollectionName");
            }
            catch
            {
            }

            return ConfigurationManager.AppSettings["ProductCollectionName"];
        }
    }
}